import plotly.express as px
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.graph_objects as go
import warnings
warnings.filterwarnings('ignore')
df1 = pd.read_excel("POLLSTER RATINGS.xlsx")
df1
df1.columns
df1.isnull().sum()
df1.info()
df1.nunique()
df1.describe()
fig = px.pie(df1.query("Year == 2020"), values="# of Polls", names="Pollster",hover_name="Year",
title='NUMBER OF POLLS vs POLLSTER corresponding YEAR --> 2020',hole=.5)
fig.update_traces(textposition='inside')
fig.update_layout({'paper_bgcolor': 'rgba(222, 993, 1000, 200)'},uniformtext_minsize=10,
uniformtext_mode='hide',font=dict(color="Blue"))
fig.show()
fig = px.pie(df1.query("Year == 2016"), values="# of Polls", names="Pollster",hover_name="Year",
title='NUMBER OF POLLS vs POLLSTER corresponding YEAR --> 2016',hole=.5,)
fig.update_traces(textposition='inside', textfont_color="Black")
fig.update_layout({'paper_bgcolor': 'rgb(0,0,0)'},uniformtext_minsize=10, uniformtext_mode='hide',font=dict(color="white"))
fig.show()
fig = px.pie(df1.query("Year == 2014"), values="# of Polls", names="Pollster",hover_name="Year",
title='NUMBER OF POLLS vs POLLSTER corresponding YEAR --> 2014',hole=.5)
fig.update_traces(textposition='inside')
fig.update_layout({'paper_bgcolor': 'rgb(255,255,160)'},uniformtext_minsize=10, uniformtext_mode='hide',font=dict(color="Black"))
fig.show()
fig = px.bar(df1.query("Year == 2020"),x="Pollster",y="# of Polls", color="Pollster",barmode="group",
animation_frame="# of Polls",animation_group="Pollster",hover_name="Year",
title='NUMBER OF POLLS vs POLLSTER corresponding YEAR --> 2020',text="# of Polls",range_y=[0,777],
range_x=['Winthrop University','SurveyUSA'])
fig.update_layout({'plot_bgcolor': 'rgba(111, 882, 999, 100)','paper_bgcolor': 'rgba(222, 993, 1000, 200)'},
uniformtext_minsize=8, uniformtext_mode='hide',showlegend = False,
xaxis={'categoryorder':'category ascending'})
fig.update_traces(texttemplate='%{text:.3s}', textposition='outside')
fig.show()
fig = px.bar(df1.query("Year == 2016"),x="Pollster",y="# of Polls", color="Pollster",barmode="group",
animation_frame="# of Polls",animation_group="Pollster",hover_name="Year",
title='NUMBER OF POLLS vs POLLSTER corresponding YEAR --> 2016',text="# of Polls",range_y=[0,777],range_x=['University of Florida','SurveyUSA'])
fig.update_layout({'plot_bgcolor': 'rgb(255,0,0)','paper_bgcolor': 'rgb(255,150,150)'},showlegend = False,
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'})
fig.update_traces(texttemplate='%{text:.3s}', textposition='outside')
fig.show()
fig = px.bar(df1.query("Year == 2014"),x="Pollster",y="# of Polls", color="Pollster",barmode="group",
animation_frame="# of Polls",animation_group="Pollster",hover_name="Year",
title='NUMBER OF POLLS vs POLLSTER corresponding YEAR --> 2014',text="# of Polls",range_y=[0,777],range_x=['Castleton State College','SurveyUSA'])
fig.update_layout({'plot_bgcolor': 'rgb(255,153,0)','paper_bgcolor': 'rgb(0,0,0)'},showlegend = False,
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'})
fig.update_traces(texttemplate='%{text:.3s}', textposition='outside')
fig.show()
fig = px.bar(df1, x="NCPP / AAPOR / Roper", y="# of Polls", color="NCPP / AAPOR / Roper",barmode="group",
animation_frame="# of Polls",animation_group="NCPP / AAPOR / Roper",range_y=[0,777],hover_name="Year",
title='NUMBER OF POLLS vs NCPP / AAPOR / ROPER',text="# of Polls")
fig.update_layout({'plot_bgcolor': 'rgba(111, 882, 999, 100)','paper_bgcolor': 'rgba(222, 993, 1000, 200)'},
uniformtext_minsize=8, uniformtext_mode='hide',xaxis={'categoryorder':'category ascending'})
fig.update_traces(texttemplate='%{text:.3s}', textposition='outside')
fig.show()
fig = px.scatter(df1, x="NCPP / AAPOR / Roper", y="# of Polls", color="NCPP / AAPOR / Roper",size_max=100,
animation_frame="# of Polls",animation_group="NCPP / AAPOR / Roper",range_y=[0,777],
size="# of Polls",hover_name="Year",
title='NUMBER OF POLLS vs NCPP / AAPOR / ROPER')
fig.update_layout({'plot_bgcolor': 'rgb(255,204,153)','paper_bgcolor': 'rgb(255,102,0)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.histogram(df1, x="NCPP / AAPOR / Roper", y="# of Polls",color="NCPP / AAPOR / Roper",
animation_frame="# of Polls",animation_group="NCPP / AAPOR / Roper",range_y=[0,777],hover_name="Year",
title='NUMBER OF POLLS vs NCPP / AAPOR / ROPER')
fig.update_layout({'plot_bgcolor': 'rgb(26,76,52)','paper_bgcolor': 'rgb(51,153,102)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.density_heatmap(df1, x="NCPP / AAPOR / Roper",y="# of Polls",range_y=[0,150],
title='NUMBER OF POLLS vs NCPP / AAPOR / ROPER')
fig.update_layout({'plot_bgcolor': 'rgb(128,0,0)','paper_bgcolor': 'rgb(128,0,0)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'})
fig.show()
from plotly import graph_objects as go
fig = go.Figure(layout={'plot_bgcolor':'skyblue','title':'NCPP / AAPOR / Roper response in corresponding YEAR'})
fig.add_trace(go.Funnel(
name = '2020',
orientation = "h",
y = ["no","yes"],
x = [339,57],marker={'color':['#DB7F93','#DB7F93']},
textposition = "inside",
textinfo = "percent total"))
fig.add_trace(go.Funnel(
name = '2016',
orientation = "h",
y = ["no","yes"],
x = [318,54],marker={'color':['#9BD353','#9BD353']},
textposition = "inside",
textinfo = "percent total"))
fig.add_trace(go.Funnel(
name = '2014',
orientation = "h",
y = ["None","yes"],
x = [283,54],marker={'color':['#A44E92','#A44E92']},
textposition = "outside",
textinfo = 'percent total'))
fig.update_layout(font=dict(color="black",size = 15),yaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.bar(df1, x="Exclusively Live Caller With Cellphones", y="# of Polls", color="Exclusively Live Caller With Cellphones",
barmode="group",hover_name="Year",
animation_frame="# of Polls",animation_group="Exclusively Live Caller With Cellphones",range_y=[0,400],
title='NUMBER OF POLLS vs EXCLUSIVELY LIVE CALLER WITH CELLPHONES',text="# of Polls")
fig.update_layout({'plot_bgcolor': 'rgb(255,204,1)','paper_bgcolor': 'rgb(255,255,1)'},
uniformtext_minsize=8, uniformtext_mode='hide',
font=dict(color="black"),xaxis={'categoryorder':'category ascending'})
fig.update_traces(texttemplate='%{text:.3s}', textposition='outside')
fig.show()
fig = px.scatter(df1, x="Exclusively Live Caller With Cellphones", y="# of Polls",
color="Exclusively Live Caller With Cellphones",
animation_frame="# of Polls",size_max=100,width=1080, height=600,hover_name="Year",
animation_group="Exclusively Live Caller With Cellphones",range_y=[0,777],size="# of Polls",
title='NUMBER OF POLLS vs EXCLUSIVELY LIVE CALLER WITH CELLPHONES')
fig.update_layout({'plot_bgcolor': 'rgb(204,204,255)','paper_bgcolor': 'rgb(0,0,128)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"))
fig.show()
fig = px.histogram(df1, x="Exclusively Live Caller With Cellphones", y="# of Polls",
color="Exclusively Live Caller With Cellphones",
animation_frame="# of Polls",animation_group="Exclusively Live Caller With Cellphones",
range_y=[0,777],hover_name="Year",
title='NUMBER OF POLLS vs EXCLUSIVELY LIVE CALLER WITH CELLPHONES')
fig.update_layout({'plot_bgcolor': 'rgb(190,190,190)','paper_bgcolor': 'rgb(150,150,150)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.density_heatmap(df1, x="Exclusively Live Caller With Cellphones",y="# of Polls",range_y=[0,150],
title='NUMBER OF POLLS vs EXCLUSIVELY LIVE CALLER WITH CELLPHONES')
fig.update_layout({'plot_bgcolor': 'rgb(255,0,255)','paper_bgcolor': 'rgb(255,180,204)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.box(df1, x="Exclusively Live Caller With Cellphones",y="# of Polls",range_y=[0,380]
,color = "Exclusively Live Caller With Cellphones",
title='NUMBER OF POLLS vs EXCLUSIVELY LIVE CALLER WITH CELLPHONES')
fig.update_layout({'plot_bgcolor': 'rgb(255,255,255)','paper_bgcolor': 'rgb(0,0,255)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.bar(df1, x="Methodology", y="# of Polls", color="Methodology",barmode="group",
animation_frame="# of Polls",animation_group="Methodology",range_y=[0,777],hover_name="Year",
title='NUMBER OF POLLS vs METHODOLOGY',text="# of Polls")
fig.update_layout({'plot_bgcolor': 'rgb(153,20,102)','paper_bgcolor': 'rgb(153,204,0)'},
uniformtext_minsize=8, uniformtext_mode='hide',
font=dict(color="white"),
xaxis={'categoryorder':'category ascending'})
fig.update_traces(texttemplate='%{text:.3s}', textposition='outside')
fig.show()
fig = px.scatter(df1, x="Methodology", y="# of Polls", color="Methodology",
animation_frame="# of Polls",size_max=100,hover_name="Year",
animation_group="Methodology",range_y=[0,777],size="# of Polls",
title='NUMBER OF POLLS vs METHODOLOGY')
fig.update_layout({'plot_bgcolor': 'rgb(255,255,150)','paper_bgcolor': 'rgb(255,0,0)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"))
fig.show()
fig = px.histogram(df1, x="Methodology", y="# of Polls",color="Methodology",
animation_frame="# of Polls",animation_group="Methodology",range_y=[0,777],
title='NUMBER OF POLLS vs METHODOLOGY')
fig.update_layout({'plot_bgcolor': 'rgb(224,255,255)','paper_bgcolor': 'rgb(0,128,128)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"))
fig.show()
fig = px.strip(df1, x="Methodology",y="# of Polls",range_y=[-1,300],hover_name="Year",color = "Methodology",
title='NUMBER OF POLLS vs METHODOLOGY')
fig.update_layout({'plot_bgcolor': 'rgb(255,255,255)','paper_bgcolor': 'rgb(0,255,0)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.box(df1, x="Methodology",y="# of Polls",range_y=[-1,200],color="Methodology",
title='NUMBER OF POLLS vs METHODOLOGY')
fig.update_layout({'plot_bgcolor': 'rgb(255,255,255)','paper_bgcolor': 'rgb(255,20,147)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.bar(df1, x="Banned by 538", y="# of Polls", color="Banned by 538",barmode="stack",
animation_frame="# of Polls",animation_group="Banned by 538",range_y=[0,777],hover_name="Year"
,title='NUMBER OF POLLS vs BANNED BY 538',text="# of Polls")
fig.update_layout({'plot_bgcolor': 'rgb(0,0,0)','paper_bgcolor': 'rgb(218,165,32)'},
uniformtext_minsize=8, uniformtext_mode='hide',
font=dict(color="white"),
xaxis={'categoryorder':'category ascending'})
fig.update_traces(texttemplate='%{text:.3s}', textposition='outside')
fig.show()
fig = px.scatter(df1, x="Banned by 538", y="# of Polls", color="Banned by 538",
animation_frame="# of Polls",size_max=100,hover_name="Year",
animation_group="Banned by 538",range_y=[0,777],size="# of Polls",
title='NUMBER OF POLLS vs BANNED BY 538')
fig.update_layout({'plot_bgcolor': 'rgb(216,191,216)','paper_bgcolor': 'rgb(139,0,139)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
)
fig.show()
fig = px.histogram(df1, x="Banned by 538", y="# of Polls",color="Banned by 538",
animation_frame="# of Polls",animation_group="Banned by 538",range_y=[0,777],
title='NUMBER OF POLLS vs BANNED BY 538')
fig.update_layout({'plot_bgcolor': 'rgb(0,255,0)','paper_bgcolor': 'rgb(255,215,0)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.density_heatmap(df1, x="Banned by 538",y="# of Polls",range_y=[0,150],
title='NUMBER OF POLLS vs BANNED BY 538')
fig.update_layout({'plot_bgcolor': 'rgb(255,0,255)','paper_bgcolor': 'rgb(127,255,212)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.strip(df1, x="Banned by 538",y="# of Polls",range_y=[-1,300],hover_name="Year",color = "Banned by 538",
stripmode='overlay',title='NUMBER OF POLLS vs BANNED BY 538')
fig.update_layout({'plot_bgcolor': 'rgb(255,255,255)','paper_bgcolor': 'rgb(0,128,0)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.box(df1, x="Banned by 538",y="# of Polls",range_y=[-1,135],color="Banned by 538",
title='NUMBER OF POLLS vs BANNED BY 538')
fig.update_layout({'plot_bgcolor': 'rgb(238,232,170)','paper_bgcolor': 'rgb(189,183,107)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.bar(df1, x="538 Grade", y="# of Polls", color="538 Grade",barmode="stack",
animation_frame="# of Polls",animation_group="538 Grade",range_y=[0,777],hover_name="Year",
title='NUMBER OF POLLS vs 538 GRADE',text="# of Polls")
fig.update_layout({'plot_bgcolor':'rgb(0,0,0)','paper_bgcolor':'rgb(218,165,32)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'})
fig.update_yaxes(showgrid=True)
fig.update_traces(texttemplate='%{text:.3s}', textposition='outside')
fig.show()
fig = px.scatter(df1, x="538 Grade", y="# of Polls", color="538 Grade",
animation_frame="# of Polls",size_max=100,hover_name="Year",
animation_group="538 Grade",range_y=[0,777],size="# of Polls",
title='NUMBER OF POLLS vs 538 GRADE')
fig.update_layout({'plot_bgcolor': 'rgba(111, 882, 999, 100)','paper_bgcolor': 'rgba(222, 993, 1000, 200)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"))
fig.show()
fig = px.histogram(df1, x="538 Grade", y="# of Polls",color="538 Grade",
animation_frame="# of Polls",animation_group="538 Grade",range_y=[0,777],
title='NUMBER OF POLLS vs 538 GRADE')
fig.update_layout({'plot_bgcolor': 'rgb(244,164,96)','paper_bgcolor': 'rgb(245,222,179)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.density_heatmap(df1, x="538 Grade",y="# of Polls",range_y=[0,150],
title='NUMBER OF POLLS vs 538 GRADE',hover_name = "Pollster")
fig.update_layout({'plot_bgcolor': 'rgb(255,0,255)','paper_bgcolor': 'rgb(127,255,212)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'})
fig.show()
from plotly import graph_objects as go
fig = go.Figure(layout={'plot_bgcolor':'skyblue','title':'NUMBER OF POLLS vs 538 GRADE'})
fig.add_trace(go.Funnel(
name = "'C' Grade",
orientation = "h",
y = ["C","C+","C-"],
x = [1193,669,433],marker={'color':['#FF1493','#FFB6C1','#FAEBD7']},
textposition = "inside",
textinfo = "value"))
fig.add_trace(go.Funnel(
name = "'B' Grade",
orientation = "h",
y = ["B+","B","B-"],
x = [794,481,367],marker={'color':['#228B22','#32CD32','#98FB98']},
textposition = "inside",
textinfo = "value"))
fig.add_trace(go.Funnel(
name = "'A' Grade",
orientation = "h",
y = ["A","A-","A+"],
x = [797,332,72],marker={'color':['#B8860B','#DAA520','#EEE8AA']},
textposition = "inside",
textinfo = 'value'))
fig.add_trace(go.Funnel(
name = "'D' Grade",
orientation = "h",
y = ["D+","D","D-"],
x = [142,104,10],marker={'color':['#00CED1','#00FFFF','#AFEEEE']},
textposition = "inside",
textinfo = 'value'))
fig.add_trace(go.Funnel(
name = "'F' Grade",
orientation = "h",
y = ["F"],
x = [219],marker={'color':['#FF0000']},
textposition = "inside",
textinfo = 'value'))
fig.update_layout(height=650,width=1000,font=dict(color="black",size = 15))
fig.show()
fig = px.box(df1, x="538 Grade",y="# of Polls",range_y=[-1,150],color = "538 Grade",
title='NUMBER OF POLLS vs 538 GRADE')
fig.update_layout({'plot_bgcolor': 'rgb(0,0,0)','paper_bgcolor': 'rgb(192,192,192)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.bar(df1, x="538 Grade", y="# of Polls",hover_name="Year",color = "Year",
range_y=[0,3500])
fig.update_layout({'plot_bgcolor': 'rgba(111, 882, 999, 100)','paper_bgcolor': 'rgba(222, 993, 1000, 200)'}
,font=dict(color="black"),yaxis=dict(showticklabels=False))
fig.show()
sns.set(rc={'axes.facecolor':'w', 'figure.facecolor':'gold'})
fig, axes = plt.subplots(5,figsize=(18,25))
sns.barplot(x=df1["538 Grade"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[0],palette="Set1")
sns.barplot(x=df1["NCPP / AAPOR / Roper"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[1],palette="Set1")
sns.barplot(x=df1["Exclusively Live Caller With Cellphones"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[2],palette="Set1")
sns.barplot(x=df1["Methodology"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[3],palette="Set1")
sns.barplot(x=df1["Banned by 538"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[4],palette="Set1")
plt.show()
sns.set(rc={'axes.facecolor':'w', 'figure.facecolor':'lightgreen'})
fig, axes = plt.subplots(5,figsize=(18,25))
sns.lineplot(x=df1["538 Grade"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[0],palette="Set1",style = df1["Year"],
markers=True, dashes=False, lw=1)
sns.lineplot(x=df1["NCPP / AAPOR / Roper"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[1],palette="Set1",style = df1["Year"]
,markers=True, dashes=False, lw=3)
sns.lineplot(x=df1["Exclusively Live Caller With Cellphones"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[2],palette="Set1",
style = df1["Year"],markers=True, dashes=False, lw=3)
sns.lineplot(x=df1["Methodology"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[3],palette="Set1",style = df1["Year"],
markers=True, dashes=False, lw=3)
sns.lineplot(x=df1["Banned by 538"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[4],palette="Set1",style = df1["Year"],
markers=True, dashes=False, lw=3)
plt.show()
sns.set(rc={'axes.facecolor':'w', 'figure.facecolor':'lightpink'})
fig, axes = plt.subplots(5,figsize=(18,25))
sns.pointplot(x=df1["538 Grade"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[0],palette="Set1",
ci=25,capsize=.1,markers = '^')
sns.pointplot(x=df1["NCPP / AAPOR / Roper"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[1],palette="Set1",
ci=25,capsize=.1,markers = '*')
sns.pointplot(x=df1["Exclusively Live Caller With Cellphones"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[2],palette="Set1",
ci=25,capsize=.1,markers = 'D')
sns.pointplot(x=df1["Methodology"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[3],palette="Set1",
ci=25,capsize=.1,markers = 's')
sns.pointplot(x=df1["Banned by 538"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[4],palette="Set1",
ci=25,capsize=.1,markers = '+')
plt.show()
sns.set(rc={'axes.facecolor':'w', 'figure.facecolor':'gold'})
fig, axes = plt.subplots(5,figsize=(18,25))
sns.boxenplot(x=df1["538 Grade"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[0],palette="Set1")
sns.boxenplot(x=df1["NCPP / AAPOR / Roper"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[1],palette="Set1")
sns.boxenplot(x=df1["Exclusively Live Caller With Cellphones"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[2],palette="Set1")
sns.boxenplot(x=df1["Methodology"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[3],palette="Set1")
sns.boxenplot(x=df1["Banned by 538"],y=df1["# of Polls"],hue=df1["Year"],ax = axes[4],palette="Set1")
plt.show()
fig = px.bar(df1,x="Pollster",y ="# of Polls for Bias Analysis",color = "Pollster",
animation_frame="# of Polls for Bias Analysis",animation_group="Pollster",hover_name="Year",
title='POLLS FOR BIAS ANALYSIS vs POLLSTER corresponding YEAR',text="# of Polls for Bias Analysis",
range_y=[0,652])
fig.update_layout({'plot_bgcolor': 'rgb(0,255,255)','paper_bgcolor': 'rgb(245,222,179)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'})
fig.show()
fig = px.pie(df1.query("Year == 2020"), values='# of Polls for Bias Analysis', names='Pollster',hover_name="Year",
hole=.5,title='POLLS FOR BIAS ANALYSIS vs POLLSTER corresponding YEAR --> 2020')
fig.update_traces(textposition='inside')
fig.update_layout({'paper_bgcolor': 'rgb(0,255,0)'},uniformtext_minsize=10,
uniformtext_mode='hide',font=dict(color="Black"))
fig.show()
fig = px.pie(df1.query("Year == 2016"), values='# of Polls for Bias Analysis', names='Pollster',hover_name="Year",
hole=.5,title='POLLS FOR BIAS ANALYSIS vs POLLSTER corresponding YEAR --> 2016')
fig.update_traces(textposition='inside')
fig.update_layout({'paper_bgcolor': 'rgb(192,192,192)'},uniformtext_minsize=10,
uniformtext_mode='hide',font=dict(color="white"))
fig.show()
fig = px.density_heatmap(df1, x="Simple Average Error", y="Simple Expected Error",
marginal_x="box", marginal_y="histogram",range_x=[0,25],hover_data=['Year','Pollster'],
title="AVERAGE ERROR & EXPECTED ERROR in YEAR")
fig.update_layout({'paper_bgcolor': 'rgb(0,255,255)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'},width = 1000)
fig.show()
fig = px.scatter(df1.query("Year != 2014"), x="Simple Average Error", y="Simple Expected Error",
title="AVERAGE ERROR & EXPECTED ERROR in YEAR",hover_data=["Year","Pollster"],
marginal_x="box", marginal_y="histogram",range_x=[0,25],range_y=[2,10])
fig.update_traces(marker=dict(size=12,
line=dict(width=2,
color='DarkSlateGrey')),
selector=dict(mode='markers'))
fig.update_layout({'paper_bgcolor': 'rgb(255,0,0)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'},width = 950,height = 500)
fig.show()
fig = px.histogram(df1, x="Predictive Plus-Minus", y="Advanced Plus-Minus", color="Year",
marginal="box",title="PREDICTIVE & ADVANCED PLUS MINUS in YEAR")
fig.update_layout({'plot_bgcolor': 'rgb(224,255,255)','paper_bgcolor': 'rgb(255,215,0)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'},width = 1000,height = 600)
fig.show()
fig = px.density_contour(df1, x="Predictive Plus-Minus", y="Advanced Plus-Minus", color="Year",
marginal_x="box", marginal_y="histogram",
range_x=[-1,1.5],range_y = [-10,10],
title="PREDICTIVE & ADVANCED PLUS MINUS in YEAR")
fig.update_layout({'plot_bgcolor': 'rgb(255,255,255)','paper_bgcolor': 'rgb(255,20,147)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'},width = 1000)
fig.show()
fig = px.density_heatmap(df1, x="Predictive Plus-Minus", y="Advanced Plus-Minus",
marginal_x="box", marginal_y="histogram",color_continuous_scale=px.colors.sequential.Cividis_r,
range_x=[-1,1.5],range_y = [-10,10],hover_data=["Year","# of Polls","Methodology"],
title="PREDICTIVE & ADVANCED PLUS MINUS in YEAR" )
fig.update_layout({'plot_bgcolor': 'rgb(128,0,128)','paper_bgcolor': 'rgb(0,128,0)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'},width = 980)
fig.show()
sns.set(rc={'axes.facecolor':'cyan', 'figure.facecolor':'khaki'})
fig, axes = plt.subplots(1,2,figsize=(20 ,8))
sns.boxplot(x=df1["Year"],y=df1["Predictive Plus-Minus"],ax = axes[0],palette="Set1")
sns.boxplot(x=df1["Year"],y=df1["Advanced Plus-Minus"],ax = axes[1],palette="Set1")
fig = px.histogram(df1.query("Year != 2016"), x="Simple Plus-Minus",y = "Mean-Reverted Advanced Plus Minus",
color="Year", marginal="box",
hover_data=["Year","Advanced Plus-Minus","Mean-Reverted Advanced Plus Minus","Predictive Plus-Minus"],
range_x=[-10,20],
title="SIMPLE & MEAN REVERTED ADVANCED PLUS MINUS in YEAR" ,
color_discrete_sequence= px.colors.sequential.Plasma_r,)
fig.update_layout({'plot_bgcolor': 'rgb(0,0,0)','paper_bgcolor': 'rgb(0,250,154)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'},width = 980,height = 600)
fig.show()
fig = px.scatter(df1.query("Year != 2016"), y="Simple Plus-Minus",x = "Mean-Reverted Advanced Plus Minus",
size="Year", size_max=25,color = "Year",marginal_x="box",marginal_y="violin",
hover_data=["Year","Advanced Plus-Minus","Mean-Reverted Advanced Plus Minus","Predictive Plus-Minus"],
color_discrete_sequence= px.colors.sequential.Tealgrn_r,
title="SIMPLE & MEAN REVERTED ADVANCED PLUS MINUS in YEAR")
fig.update_traces(marker=dict(size=22,
line=dict(width=2,
color='DarkSlateGrey')),
selector=dict(mode='markers'))
fig.update_layout({'plot_bgcolor': 'rgb(245,255,250)','paper_bgcolor': 'rgb(128,0,0)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="White"),
xaxis={'categoryorder':'category ascending'},width = 1080,height = 600)
fig.show()
fig = px.density_contour(df1.query("Year == 2020"),x = "Bias",y = "House Effect",range_x=[-10,10],
animation_frame="Pollster",range_y=[-2.5,5.0],hover_data=["Bias","House Effect"],
title="BIAS & HOUSE EFFECT in YEAR --> 2020",
color="Pollster")
fig.update_traces(line_width=2)
fig.update_layout({'plot_bgcolor': 'rgb(255,255,255)','paper_bgcolor': 'rgb(255,69,0)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),
xaxis={'categoryorder':'category ascending'},width = 980)
fig.show()
fig = px.density_heatmap(df1.query("Year == 2020"),x = "Bias",y = "House Effect",range_x=[-25,20],
range_y=[-20,20],hover_data=["Bias","House Effect"],
color_continuous_scale=px.colors.sequential.Viridis_r,
title="BIAS & HOUSE EFFECT in YEAR --> 2020" )
fig.update_layout({'paper_bgcolor': 'rgb(255,20,147)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="white"),width = 980)
fig.show()
fig = px.histogram(df1.query("Year == 2020"),x = "Bias",y = "House Effect",color="Year",
marginal="box",color_discrete_sequence=px.colors.sequential.Cividis_r,range_x=[-25,25],
title="BIAS & HOUSE EFFECT in YEAR --> 2020")
fig.update_layout({'plot_bgcolor': 'rgb(0,0,0)','paper_bgcolor': 'rgb(0,250,154)'},showlegend=False,
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'},width = 980,height = 600,
)
fig.show()
fig = px.scatter(df1.query("Year == 2020"),x="Pollster",y="Misses Outside MOE",color="Pollster",
marginal_x="rug",marginal_y = "histogram",
title = "MISSES OUTSIDE MOE vs POLLSTER in YEAR --> 2020")
fig.update_traces(marker=dict(size=25,line=dict(width=1,color='DarkSlateGrey')),
selector=dict(mode='markers'))
fig.update_layout({'plot_bgcolor': 'rgb(245,255,250)','paper_bgcolor': 'rgb(255,215,0)'}
,font=dict(color="black"),xaxis=dict(showticklabels=False)
,width = 980,height = 550,showlegend = False)
fig.show()
fig = px.bar(df1.query("Year == 2020"),x="Pollster",y="Misses Outside MOE", color="Pollster",barmode="group",
animation_frame="Misses Outside MOE",animation_group="Pollster",hover_name="Year",range_y=[0,1],
title='MISSES OUTSIDE MOE vs POLLSTER in YEAR --> 2020',text="Misses Outside MOE")
fig.update_layout({'plot_bgcolor': 'rgb(238,232,170)','paper_bgcolor': 'rgb(218,165,32)'},
uniformtext_minsize=8, uniformtext_mode='hide',font=dict(color="black"),
xaxis={'categoryorder':'category ascending'})
fig.update_traces(texttemplate='%{text:1%s}', textposition='outside')
fig.show()